package app.fugema.shop.main.home.adapter;

import android.view.View;


import com.base.common.model.bean.ADInfo;
import com.base.common.view.adapter.MyFlexboxLayoutManager;
import com.base.common.view.adapter.ada.SingleRecyclerAdapter;
import com.base.common.view.adapter.connector.BaseViewHolder;
import app.fugema.shop.R;
import app.fugema.shop.databinding.HomeSearchDrawerItemBinding;

import java.util.ArrayList;
import java.util.List;

public class HomeSearchDrawerAdapter extends SingleRecyclerAdapter<ADInfo, HomeSearchDrawerItemBinding> {

    @Override
    public int getLayoutId() {
        return R.layout.home_search_drawer_item;
    }

    @Override
    public void onCreateViewHolder(HomeSearchDrawerItemBinding binding, BaseViewHolder viewHolder) {
        super.onCreateViewHolder(binding, viewHolder);
        binding.rvRecyclerView.setLayoutManager(new MyFlexboxLayoutManager(viewHolder.itemView.getContext()));
        HomeSearchDrawerItemAdapterMultiTypeInterface itemAdapter = new HomeSearchDrawerItemAdapterMultiTypeInterface();
        itemAdapter.setRadio(true);
        binding.rvRecyclerView.setAdapter(itemAdapter);
    }

    @Override
    public void onBindViewHolder(HomeSearchDrawerItemBinding binding, int position, ADInfo bean) {
        super.onBindViewHolder(binding, position, bean);
        binding.tvTitle.setText(bean.getImageName());
        if (bean.getCount() == 1) {
            binding.tvMore.setVisibility(View.VISIBLE);
        } else {
            binding.tvMore.setVisibility(View.GONE);
        }

        if (binding.rvRecyclerView.getAdapter() instanceof HomeSearchDrawerItemAdapterMultiTypeInterface) {
            HomeSearchDrawerItemAdapterMultiTypeInterface itemAdapter = (HomeSearchDrawerItemAdapterMultiTypeInterface) binding.rvRecyclerView.getAdapter();

            List<ADInfo> list = new ArrayList<>();

            ADInfo adInfo1 = new ADInfo();
            adInfo1.setImageName("全年龄犬");
            adInfo1.setCount(0);
            list.add(adInfo1);

            ADInfo adInfo2 = new ADInfo();
            adInfo2.setImageName("幼犬");
            adInfo2.setCount(1);
            list.add(adInfo2);

            ADInfo adInfo3 = new ADInfo();
            adInfo3.setImageName("仅看有货");
            adInfo3.setCount(2);
            list.add(adInfo3);

            ADInfo adInfo4 = new ADInfo();
            adInfo4.setImageName("国产");
            adInfo4.setCount(3);
            list.add(adInfo4);

            itemAdapter.setDataList(list);
        }


    }


}
